//
//  ZNoticeDetailVC.m
//  WeClubs
//
//  Created by 花花 on 2017/6/22.
//  Copyright © 2017年 Zed. All rights reserved.
//

#import "ZNoticeDetailVC.h"
#import "ZClubsListHeaderView.h"
#import "ZNoticeDetaCell.h"
@interface ZNoticeDetailVC ()<UITableViewDelegate,UITableViewDataSource>
//tableView
@property(nonatomic)UITableView *tableView;

@property(nonatomic)NSMutableArray *noticeDetaArr;
@end

static NSString *const ZNoticeDetaCellID = @"ZNoticeDetaCellID";
@implementation ZNoticeDetailVC

#pragma mark - Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initUI];
    self.title = @"确认详情";
}
#pragma mark - setupNav
- (void)zConfigNavigation{
    [super zConfigNavigation];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self zAddBackItemWithGesture:YES];
    
    self.navigationItem.rightBarButtonItem  = [self zNavItemWithTitle:@"再次通知" andSelector:@selector(navRightOnClick)];
    
}

- (void)navRightOnClick{
 
    [self loadDataFormNetWork];

}
#pragma mark - init Methods
-(void)initUI{
    
    [self.view addSubview:self.tableView];
    
    
}
#pragma mark - loadData
- (void)loadDataFormNetWork{
    
    [MBProgressHUD zAlertProgress:@"正在加载中"];
    NSDictionary *params = @{
                             @"notify_id":@(12),
//
                             };
    [HTTPRequest POST:kGet_notify_check_statusUrl parameter:params success:^(id resposeObject) {
        [MBProgressHUD zAlertHideHUD];
        
        if ([resposeObject[@"result_code"] integerValue] == ZNetManagerStatusSuccess) {
            for (NSDictionary *dict in resposeObject[@"data"]) {
                
                [self.noticeDetaArr addObject:dict];
    
            }
            [self.tableView reloadData];
        }else{
            
            [MBProgressHUD zAlertMessage:resposeObject[@"result_msg"] to:self.view afterDelay:1.0];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD zAlertHideHUD];
    }];
    
}

#pragma mark - UITableViewDelegate & UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    ZNoticeDetaCell *cell = [tableView dequeueReusableCellWithIdentifier:ZNoticeDetaCellID];
    
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    ZNoticeDetaHeaderView *headerView = [[ZNoticeDetaHeaderView alloc]init];
    return headerView;

}


#pragma mark - Custom Methods

#pragma mark - Setter && Getter Methods
-(UITableView *)tableView{
    
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,64, Z_SCREEN_WIDTH, Z_SCREEN_HEIGHT-64) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
//        [_tableView setBackgroundColor:GENERAL_VIEW_BG_COLOR];
//        _tableView.separatorColor = GENERAL_VIEW_BG_COLOR;
        _tableView.rowHeight = 80;
        [_tableView registerNib:[UINib nibWithNibName:@"ZNoticeDetaCell" bundle:nil] forCellReuseIdentifier:ZNoticeDetaCellID];
    }
    return _tableView;
}
- (NSMutableArray *)noticeDetaArr{

    if (!_noticeDetaArr) {
        _noticeDetaArr = [NSMutableArray array];
    }
    
    return _noticeDetaArr;


}

@end
